package com.nl.controller.web.controller;

import com.github.pagehelper.PageInfo;
import com.nl.controller.common.model.Response;
import com.nl.controller.common.util.ResponseUtil;
import com.nl.controller.web.service.SmsFiedService;
import com.nl.controller.web.bean.SmsFied;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("fied")
@Slf4j
public class SmsFiedController {

@Autowired
private SmsFiedService smsFiedService;

    @ApiOperation(value = "统计外来人口", notes = "分页查询外来人口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "limit", value = "每页数量", required = true, dataType = "String"),
            @ApiImplicitParam(name = "cityId", value = "地市编号", required =false,dataType = "String"),
            @ApiImplicitParam(name = "mgrId", value = "项目编号", required =false,dataType = "String"),
            @ApiImplicitParam(name = "regionId", value = "区域编号", required =false, dataType = "String"),
            @ApiImplicitParam(name = "stationId", value = "基站编号", required =false,dataType = "String"),
            @ApiImplicitParam(name = "way", value = "统计方式", required =true,dataType = "String"),
            @ApiImplicitParam(name = "month", value = "月份", required =false,dataType = "String"),
            @ApiImplicitParam(name = "startTime", value = "发送时间", required =false, dataType = "String"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required =false,dataType = "String")
    })
    @PostMapping("find")
    public Response findFied(
            @RequestParam(value = "page", required = true) int page,
            @RequestParam(value = "limit", required = true) int limit,
            @RequestParam(value = "cityId",required =false) String cityId,
            @RequestParam(value = "mgrId",required =false) String mgrId,
            @RequestParam(value = "regionId",required =false) String regionId,
            @RequestParam(value = "stationId",required =false) String stationId,
            @RequestParam(value = "month",required =false) String month,
            @RequestParam(value = "way",required =false) String way,
            @RequestParam(value = "startTime",required =false) String startTime,
            @RequestParam(value = "endTime",required =false) String endTime,
            @RequestParam Map<String, Object> paramMap
    ) {
        PageInfo<SmsFied> pageInfo = smsFiedService.countFied(page, limit,cityId,mgrId,regionId,stationId,way,month,startTime,endTime);
        log.info(" 外来统计参数：{}",paramMap.toString());
        log.debug("外来统计返回数据：{}",pageInfo.getList().toString());
        return ResponseUtil.sucess(pageInfo.getList(), pageInfo.getTotal());
    }
}
